<template>
    <div class="TabControl">
        <div v-for="(item,index) in titles" class="TabControlItem">
            <span @click="spanClick(index)" :class="{active : index === currentIndex}">{{item}}</span>
        </div>
    </div>
</template>

<script>
    export default{
        name : 'TabControl',
        props : {
            titles : {
                type : Array,
                default(){
                    return []
                }
            }
        },
        data(){
            return {
                currentIndex : 0
            }
        },
        methods : {
            spanClick(index){
                this.currentIndex = index
                this.$emit('tabClick',index)
            }
        }
    }
</script>

<style scoped>
.TabControl{
    display: flex;
    background-color: white;
}
.TabControlItem{
    flex: 1;
    text-align: center;
    line-height: 40px;
    font-size: 15px;
}
.active{
    color : var(--color-high-text);
    border-bottom: 3px solid var(--color-tint);
    padding: 5px;
}
</style>